package com.wendu.oa.leave.dao.leave;

import com.wendu.oa.leave.dto.LeaveDto;
import com.wendu.oa.leave.model.Leave;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ApprevDao {

    List<Leave> findAppList(LeaveDto leaveDto);

    @Insert("insert into t_leave(l_id,e_id,l_start,l_end,l_cause,l_status) values(#{l_id},#{e_id},#{l_start},#{l_end},#{l_cause},#{l_status})" )
    void insertNewLeave(LeaveDto leaveDto);

    @Select("select count(l_id) from t_leave where l_id = #{l_id} and e_id = #{e_id}")
    boolean findExistsLeaveByEidAndLid(LeaveDto leaveDto);

    @Select("select count(l_id) from t_leave where l_id = #{l_id} and l_status = 0 ")
    boolean findIsUncommitedLeave(String l_id);

    @Update("update t_leave set l_date = #{l_date} , l_status = 1 where l_id= #{l_id}")
    void updateStatusCommited(LeaveDto l_id);

    @Select("select count(l_id) from t_leave where l_id = #{l_id} and l_status = 3 ")
    boolean findIspassedLeave(String l_id);

    @Update("update t_leave set l_back = #{l_back} , l_status = 4 where l_id= #{l_id}")
    void updateStatusRev(LeaveDto leaveDto);
}
